package com.example.meetingroomnew.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.meetingroomnew.Dao.UserDao;
import com.example.meetingroomnew.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserDao userDao;
    @Override
    public User selectByid(int id) {
        User user = userDao.selectById(id);
        return  user;
    }

    @Override
    public int AddNewUser(User user) {
        userDao.insert(user);
        LambdaQueryWrapper<User> qw=new LambdaQueryWrapper<User>();
        qw.select(User::getId).last("LIMIT 1").orderByDesc(User::getId);
        User user1 = userDao.selectOne(qw);
        return user1.getId();
    }
}
